package com.sonicvision.resourcetracker.employee;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sonicvision.resourcetracker.exceptions.DAOException;
import com.sonicvision.resourcetracker.exceptions.ServiceException;

@Service
public class EmployeeServiceImpl implements EmployeeService {

	@Autowired
	private EmployeeDAO dao;

	@Autowired
	private EmployeeAddressDAO addressDao;

	@Override
	@Transactional
	public void addEmployee(Employee employee) throws ServiceException {

		try {
			dao.addEmployee(employee);
		} catch (DAOException e) {
			e.printStackTrace();
		}

	}

	@Override
	@Transactional
	public void addEmpAddress(EmployeeAddress employeeAddress)
			throws ServiceException {

		try {
			addressDao.addEmpAddress(employeeAddress);
		} catch (DAOException e) {
			e.printStackTrace();
		}

	}

	@Override
	public List<Employee> getListOfEmployees() throws ServiceException {

		List<Employee> listOfEmployees = null;
		try {
			listOfEmployees = dao.getListOfEmployees();
		} catch (DAOException e) {
			e.printStackTrace();
		}

		return listOfEmployees;
	}

	@Override
	public Employee findByPrimaryKey(int employeeId) throws ServiceException {

		Employee employee = null;
		try {
			employee = dao.findByPrimaryKey(employeeId);
		} catch (DAOException e) {
			e.printStackTrace();
		}

		return employee;
	}

	@Override
	public void updateEmployee(Employee employee) throws ServiceException {

	}

	@Override
	public void deleteEmployee(int employeeId) throws ServiceException {

	}

}
